<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<link href="../../../element/index.css" rel="stylesheet" />
		<script src="../../../js/vue.js"></script>
		<script src="../../../element/index.js"></script>
		<script src="../../../js/axios.js"></script>
		<script src="../../../js/gsaucommon.js"></script>
		<title></title>
		<style>
			* {
				margin: 0;
				padding: 0;
			}

			#app {
				width: 1200px;
				margin: 30px auto;
				box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
			}

			.el-header {
				margin-top: 10px;
				height: 300px;
			}

			.name {
				height: 50px;
				position: sticky;
				top: 0px;
				z-index: 999;
				background-color: white;
				border: 2px solid #F8F8FF;
				margin-top: 0px;
			}

			.title {
				width: 150px;
				height: 40px;
				margin-top: 15px;
				text-align: center;
			}

			.add-data {
				width: 150px;
				height: 40px;
				margin-top: 8px;
				margin-left: 35px;
			}

			.search {
				width: 230px;
				height: 40px;
				margin-top: 7px;
				font-size: 15px;
			}

			.search_span {
				font-size: 15px;
				padding-left: 50px;
				margin-top: 15px;
			}

			.status {
				width: 350px;
				margin-top: 7px;
				height: 40px;
				font-size: 15px;
			}

			.search-icon {
				width: 600px;
				margin-top: 15px;
				height: 40px;
				font-size: 15px;
			}

			.el-main {}

			.main_text {
				width: 1100px;
				margin: 0 auto;
			}

			.el-footer {
				height: 40px;
			}

			.page {
				width: 550px;
				margin: 15px auto;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<el-container>
				<el-header class="name">
					<el-row>
						<el-col :span="21">
							<div class="title">
								<h3>指导竞赛审核</h3>
							</div>
						</el-col>
						<el-col :span="1">
							<div class="add-data">
							<!-- 	<el-button type="primary">
									<el-link href="addJingSai.html" style="color: white;">添加</el-link>
								</el-button> -->
							</div>
						</el-col>
					</el-row>

				</el-header>
				<!-- 页眉 -->
				<el-header>
					<el-row>
						<el-col :span="2">
							<div class="search_span">名称：</div>
						</el-col>
						<el-col :span="8">
							<div class="search">
								<el-input v-model="jingsaiName" placeholder="请输入关键词"> </el-input>
							</div>
						</el-col>
						<el-col :span="11">

							<div class="status">
								<span>流程状态：</span>
								<el-select placeholder="请选择" v-model="rules.node">
									<!-- <el-option label="进行中"  @click.native="checkDoing()"></el-option> -->
									<el-option v-for="(item,index) in node " :label="item.name" :value="item.name" :key=index   @click.native="check()"></el-option>
									<el-option label="全部" value="" @click.native="check()"> </el-option>
									</el-form-item>



									<!-- 	<el-dropdown @command="handleCommand">
								<span>流程状态：</span>
								<el-select  placeholder="请选择"  v-model="status" value="status" >
								<el-dropdown-menu slot="dropdown">
							    <el-dropdown-item command="审核中">审核中</el-dropdown-item>
							    <el-dropdown-item command="审核已完成">审核已完成</el-dropdown-item>
							    <el-dropdown-item command="取消">取消</el-dropdown-item>
							  </el-dropdown-menu>					
							
							 </el-dropdown>		</el-select> -->
							</div>
						</el-col>
						<el-col :span="3">
							<div class="search-icon">
								<el-button type="primary" size="small" icon="el-icon-search" @click="search()">搜索
								</el-button>
							</div>
						</el-col>
					</el-row>
				</el-header>
				<!-- 正文 -->
				<el-main>
					<el-row>
						<el-col :span="24">
							<div class="main_text">

								<el-table :data="tableData" style="width: 100%;text-align: center;" border
									highlight-current-row>
									<el-table-column type="index" :index="myIndex" label="序号" width="50px">
									</el-table-column>
									<el-table-column prop="tianbaoName" label="填报人" width="80"></el-table-column>
									<el-table-column prop="jingsaiName" label="名称" width="300"></el-table-column>
									<el-table-column prop="createTime" label="提交时间" width="160"></el-table-column>
									<el-table-column prop="node" label="当前节点" width="100"></el-table-column>
									<el-table-column prop="zuzhiDanWei" label="组织单位" width="140"></el-table-column>
									<el-table-column label="操作" width="250" prop='status'>
										<template slot-scope="scope" >
											<el-row style="text-align: center;">
											  <el-col :span="8"><div class="grid-content bg-purple">
											  <el-button  type="primary" size="mini" @click="toUpdate(scope.row)">
											  	审核
											  </el-button>
											  </div></el-col>
											
											</el-row>
											
										</template>
										    <!-- <template slot-scope="scope">
										        <el-button
										          size="mini"
										          @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
										        <el-button
										          size="mini"
										          type="danger"
										          @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
										      </template> -->

									</el-table-column>
								</el-table>

							</div>
						</el-col>
					</el-row>
				</el-main>
				<!-- 页尾 -->
				<el-footer>
					<el-row>
						<el-col :span="24">
							<div class="page">
								<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
									:current-page="page_index" :page-sizes="page_sizes" :page-size="page_size"
							 	layout="total,sizes, prev, pager, next, jumper" :total="totalpage">
								</el-pagination>
							</div>
						</el-col>
					</el-row>
				</el-footer>
			</el-container>
		</div>
	</body>
</html>
<script>
	//3:由Vue挂载elements
	new Vue({
		el: "#app",
		data: {
			page_size: 5,
			page_sizes: [5, 10, 20, 40],
			page_index: 1,
			pages: '',
			totalpage: 0,
			jingsaiName: '',
			rules: {
				pageIndex: 1,
				pageSize: 5,
				tianbaoId: null,
				node:'待审核',
				jingsaiName: '',

			},
			node:[],
			tableData: [1],
			search_options: [{
				value: 'tableData.project',
			}],
			status_options: [{
				value: '选项1',
				label: '审核中',
			}, {
				value: '选项2',
				label: '审核完成',
			}],
		},
		methods: {

			open(val,index) {
				this.$confirm('是否删除?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning',
					
				}).then(()=>{
					this.remove(val,index)
					
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消提交'
					});
				});
				
			},

			//检查是否显示删除和修改
			checkShow(val){
				if(val.node=="待审核")
				return true
				else
				return false
			},
			//删除数据
			remove(val,index) {
				
			if(index==0&&this.page_size*(this.page_index-1)+index+1==this.totalpage){
				this.page_index=this.page_index-1
			}
			axios.delete(window.gsau+"zhidaojingsai/delete/"+val.id).then((response)=>{
					if(response.data.code==20010)
					this.$message.success("删除成功")
					else
					this.$message.error("删除失败,请稍后再试")
					// if(response.code==)
					
				}).finally(()=>{
					
					this.findAll()
				}
				)
			},
			toShow(val) {
				sessionStorage.setItem("show_id",val.id)
				window.location = "chaKanJingSai.html"
			},
			toUpdate(val) {			
				sessionStorage.setItem("jingsai_review_id",val.id)
				console.log(val.id)
				window.location = "reviewZhidaojinsai.html"
			},
			handleSizeChange(val) {
				this.page_size = val
				// console.log(val + "fdsafsdf+++++++++++++++++++")
				this.findAll()

			},
			//显示数据自定义索引
			myIndex(index) {
				//     当前序号 + ( 当前页数 - 1 ) * 每页条数 + 1
				return index + ((this.page_index - 1) * this.page_size) + 1
			},
			handleCurrentChange(val) {
				this.page_index = val
				console.log("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnntttttttttttttttttt")
				this.findAll()
			},

			//点击搜索搜索方法
			search() {
				this.rules.jingsaiName = this.jingsaiName
				this.findAll()

			},

			//点击审核栏
			checkDoing(){
				
			},
			check() {
				console.log(this.rules)
				this.page_index = 1
				this.findAll()
			},
			findNode(){
					axios.get(window.gsau+"node/findnode/").then((res)=>{
						if(res.data.code==40010)
						this.node=res.data.data
						else{
							this.$message.error("系统异常")
						}
		
						
					})
			},

			//查询方法
			findAll() {

							
				this.rules.pageIndex = this.page_index
				this.rules.pageSize = this.page_size
				this.rules.tianbaoId = sessionStorage.getItem("tianbaoId")
				this.rules.jingsaiName = this.jingsaiName
				// this.rules.node=this.node
				console.log(this.totalpage)
				if(sessionStorage.getItem("rules")!=''&&sessionStorage.getItem("rules"!=null)){
					
					this.rules=sessionStorage.getItem("rules")
				}

				axios.post(window.gsau+"zhidaojingsai/rules/", this.rules).then((res) => {
					if(res.data.code==10010){
						this.tableData = res.data.data.records
						this.totalpage = res.data.data.total
						this.page_size = res.data.data.size
						this.page_index = res.data.data.current
					}else{
						this.$message.error("系统异常")
					}

				}).finally(() => {

				})
			}

		},
		created: function() {
			sessionStorage.setItem("user", "赵文浩")
			// sessionStorage.setItem("tianbaoId", 7)
			this.findNode()
			this.findAll()
		},
	})
</script>
